<link type="text/css" href="<?=base_url()?>css/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="<?=base_url()?>js/ui/ui.core.js"></script>
<script type="text/javascript" src="<?=base_url()?>js/ui/ui.datepicker.js"></script>
<script type="text/javascript">
$j(document).ready(function(){
	$j("#from-date").datepicker({ dateFormat: 'yy-mm-dd' });
	$j("#to-date").datepicker({ dateFormat: 'yy-mm-dd' });
	switchtype();
});
function switchtype() {
	var type = $j('#coupontype').val();
	if(type == 1) { $j('#cp-title').html('%'); }
	else if(type == 2) { $j('#cp-title').html('$'); }
}
</script>
    	<div class="left">
        	<h1>System Settings</h1>
            <div class="bar">

            	<div class="text">Coupons & Discounts &raquo; Edit Coupon</div>
            	<div class="cr"></div>
            </div>
            <div class="box">
            	<input type="button" class="button rounded" value="Back to Coupons List" onclick="history.go(-1)" />
            </div>
            <hr />
            <form method="post" action="<?=base_url()?>admin/system/updatecoupon">
            <input type="hidden" name="id" value="<?=$coupon['id']?>" />
            <div class="box bgw">
            	<h3>Basic Information</h3>
                <p class="desc">Please enter following information to create new coupon code for your shopping cart.</p><br />
                <dl class="two"><dt>Coupon name</dt><dd><input type="text" class="textfield rounded" name="name" value="<?=$coupon['name']?>" /></dd></dl>
                <dl class="four"><dt>Coupon code</dt><dd><input type="text" class="textfield rounded" name="code" value="<?=$coupon['code']?>" /></dd><?php if($this->session->flashdata('duplicate')) { ?><dd class="error">ERROR: This code has been used in the system.</dd><?php } ?></dl>
                <dl class="two"><dt>Permanent</dt><dd><input type="checkbox" name="permanent"<?php if($coupon['permanent']) print ' checked="checked"'; ?> /> This coupon code will be valid as long as it is actived</dd></dl>
                <dl class="four"><dt>From date</dt><dd><input type="text" class="textfield rounded" name="from_date" id="from-date" value="<?=$coupon['from_date']?>" /></dd><dd>To date</dd><dd><input type="text" class="textfield rounded" name="to_date" id="to-date" value="<?=$coupon['to_date']?>" /></dd></dl>
            	<dl></dl>
            </div>
            <hr />
            <div class="box">
            	<h3>Value & Condition</h3>
                <dl class="four"><dt>Coupon type</dt><dd>
                	<select name="type" id="coupontype" onchange="switchtype()">
                    	<option value="1"<?php if($coupon['type'] == 1) print ' selected="selected"'; ?>>Percentage</option>
                        <option value="2"<?php if($coupon['type'] == 2) print ' selected="selected"'; ?>>Absolute</option>
                    </select>
                </dd><dd><input type="text" class="textfield rounded" name="value" value="<?=$coupon['value']?>" /> <span id="cp-title">%</span></dd></dl>
                <dl class="four"><dt>&nbsp;</dt><dd><p class="desc">With the set price shipping method you can set 2 parameters. The set price dollar amount and the<br />condition for when this will be applied such as when a user spends more than $50 a set price will be<br /> applied such as $5</p></dd></dl>
                <dl class="four"><dt>Condition</dt><dd>If they spend more than</dd><dd class="small"><input type="text" class="textfield rounded" name="condition" value="<?=$coupon['condition']?>" /></dd><dd>Enter a number in format 00.00</dd></dl>
                <dl class="four"><dt>Sale items exclude</dt><dd><input type="checkbox" name="sale_exclude"<?php if($coupon['sale_exclude']) print ' checked="checked"'; ?> /></dd></dl>
                <dl></dl>
			</div>
            <hr />             
            <div class="box bgw">
                <dl class="four"><dt>&nbsp;</dt><dd><input type="submit" class="button rounded" value="Update coupon" /></dd><?php if($this->session->flashdata('updated')) { ?><dd class="green">This coupon has been updated successfully</dd><?php } ?></dl>
                <dl></dl>
            </div>
            </form>
        </div>
        
